<?php 

/***********************头部***********************/
$title = '新闻中心';

$css = 'news_center';

$tpid =3;

/********************************************************二级菜单************************************************/


	//header 当前状态效果
	$hid =isset($_GET['hid'])?$_GET['hid']:$tpid;
	//当前页类信息
	
	$curcate = dbselOne($con,'category','*',$tpid);

	//二级类信息
	$secondary = dbselect($con,'category','*',"pid=$tpid");
	
	
	//二级菜单当前状态效果
	$sid = isset($_GET['sid'])?$_GET['sid']:$secondary[0]['id'];

	//当前二级类信息

	$cursec = dbselOne($con,'category','*',$sid);



/******************************分页*************************/
// $p = isset($_GET['p'])?$_GET['p']:1;

// $num = 5;
// 	//除去的条数
// $c = ($p-1)*$num;
// //   dbselect($con,$table,$field='*',$where='',$order='',$limit='')
// $data = dbselect($con,'news','title,remark,create_time','','create_time desc',"{$c},{$num}");


// page($con,$table,$p,$num)
// $page = page($con,'news',$p,$num);

//dbselect($con,$table,$field='*',$where=null,$order=null,$limit=null)
	
	//总条数
	$rows = count(dbselect($con,'news','*',"category_id=$sid"));
	//每页条数
	$num = 5;
	//当前页
	$p = isset($_GET['p'])?$_GET['p']:1;
	//除去的条数
	$c = ($p-1)*$num;

	$data = dbselect($con,'news','id,title,remark,create_time',"category_id=$sid",'create_time desc',"{$c},{$num}");
	
	//页码
	//page($con,$table,$p,$num,$tag='',$tag,$etag)
	$tag = "<li>";
	$etag = "</li>";
	$purl = "&m=".M.'&c='.C.'&v='.V.'&sid='.$sid.'&hid='.$hid;
	$page = page($con,'news',$p,$rows,$num,$purl,$tag,$etag);

	foreach($data as $k => $v){
		$data[$k]['d_time'] = date('d',$v['create_time']);
		$data[$k]['Ym_time'] = date('Y/m月',$v['create_time']);
	}


	//banner图查询
	$banner = dbselect($con,'banner','*',"cate_id='{$hid}' and status = 1",'create_time desc','1');

	if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH'])=='xmlhttprequest'){

		$list['page'] = $page;

		$list['data'] = $data;

		$list['hid'] = $hid;

		$list['sid'] = $sid;

		$list['img'] = IMG;

		echo json_encode($list);die;

	}
		




// var_dump($page);die;

require("application/home/views/public/header.html");

include("application/".M."/views/".C."/".V.".html");

require("application/home/views/public/footer.html");


?>